package cn.zhang.violet.Tools

import cn.zhang.violet.config.ConfigHandler
import cn.zhang.violet.utils.Jpools
import org.apache.spark.{SparkConf, SparkContext}

/**
  * 在这个类里面连接redis
  */
object DataToRedis {
  def main(args: Array[String]): Unit = {
    val sparkConf = new SparkConf()
    sparkConf.setMaster("local[*]")
    sparkConf.setAppName(this.getClass.getSimpleName)
    sparkConf.set("spark.serializer","org.apache.spark.serializer.KryoSerializer")

    val sc = new SparkContext(sparkConf)
  //读取字典数据
    sc.textFile(ConfigHandler.appdictFilePath)
      .map(t=>t.split("\t",-1))
      .filter(t=>t.length >=5)
      .foreachPartition( iter => {
          val jedis = Jpools.getJedis
        iter.foreach( data => {
          val appname = data(1)
          val appid = data(4)

        })
          jedis.close()
      })
      sc.stop()
  }
}
